<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=5.0,minimum-scale=0.5">
    <title>Document</title>
    <style>
        .outer{
            border: 10px solid green;
            
        }
        /* 高度塌陷  由于浮动造成的 */
        .outer div{
            width: 100px;
            height: 100px;
            float: left;
        }
        .outer div:nth-child(2n){
            background: olive;
        }
        .outer div:nth-child(2n+1){
            background: red;
        }
        .outer::after{
            content: '';
            display: block;
            /* 块元素的特点   独占一行 */
            clear: both;
            height: 0px;
        }


    </style>
</head>
<body>
    <div class="outer">
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
    </div>
</body>
</html>